package com.ruoyi.pingan.fymodule.thirdpa.api.impl;

import com.alibaba.fastjson.JSONObject;
import com.ruoyi.pingan.config.TaskExecutePoolConfig;
import com.ruoyi.pingan.fymodule.account.service.ISxoSafetyLogService;
import com.ruoyi.pingan.fymodule.account.util.PaPayUtil;
import com.ruoyi.pingan.fymodule.thirdpa.api.BaseClient;


/**
 * 会员间交易-验证短信动态码(KFEJZB6101)
 */
public class MemberTranVerifyTextMsgsApi extends BaseClient {

    private final ISxoSafetyLogService sxoSafetyLogService;
    private final TaskExecutePoolConfig taskExecutePoolConfig;

    public MemberTranVerifyTextMsgsApi(ISxoSafetyLogService sxoSafetyLogService, TaskExecutePoolConfig taskExecutePoolConfig){
        this.sxoSafetyLogService=sxoSafetyLogService;
        this.taskExecutePoolConfig=taskExecutePoolConfig;
    }

    @Override
    public String getApiUrl() {
        return PaPayUtil.MEMBER_TRANVERIFY_TEXT_MSGS;
    }

    @Override
    public void saveResult(String logId, String result) {
        taskExecutePoolConfig.getAsyncExecutor().execute(() -> {
            sxoSafetyLogService.updateSafetyLog(logId, result);
        });
    }

    @Override
    public String saveLog(JSONObject params) {
        String busId = params.getString("OutSubAcctNo");
        return sxoSafetyLogService.saveSafetyLog("", busId, PaPayUtil.MEMBER_TRANVERIFY_TEXT_MSGS, params.toJSONString());
    }
}
